package com.zcg.blogger.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zcg.blogger.dao.MessageDao;
import com.zcg.blogger.model.Message;
import com.zcg.blogger.pojo.Pager;
import com.zcg.blogger.service.MessageService;

@Service("messageService")
public class MessageServiceImpl implements MessageService{
	
	@Resource
	private MessageDao messageDao;
	
	@Override
	public void add(Message message) {
		message.setTime(new Date());
		this.messageDao.insert(message);
	}

	@Override
	public List<Message> loadMessageAll() {
		Map map = new HashMap();
		map.put("pageOffset", Pager.getPager().getPageOffset());
		map.put("pageSize", Pager.getPager().getPageSize());
		return messageDao.selectAll(map);
	}

	@Override
	public int countAll() {
		return messageDao.countAll();
	}

}
